package com.reremouse.rerebbs.web.mb;

import com.reremouse.rerebbs.dao.IBbsUserDAO;
import com.reremouse.rerebbs.model.BbsUser;
import com.reremouse.util.JsfHelper;
import com.reremouse.util.SpringHelper;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;

@ManagedBean
@ViewScoped
public class UserCenter
        implements Serializable {
    private IBbsUserDAO userDAO = (IBbsUserDAO) SpringHelper.getSpringBean("BbsUserDAO");
    private BbsUser user;

    public BbsUser getUser() {
        return this.user;
    }

    public void setUser(BbsUser user) {
        this.user = user;
    }

    @PostConstruct
    public void init() {
        HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
        String temp = request.getParameter("id");
        if (temp != null) {
            this.user = this.userDAO.findBbsUser(Long.parseLong(temp));
        } else {
            ClientSession cs = (ClientSession) JsfHelper.getBean("clientSession");
            this.user = cs.getUsr();
        }
    }
}



/* Location:           F:\jsp源码\蝙蝠论坛系统\rerebbs\WEB-INF\classes\

 * Qualified Name:     com.reremouse.rerebbs.web.mb.UserCenter

 * JD-Core Version:    0.7.0.1

 */